package com.supcon.exchangedata.repository.slave4;


import com.supcon.exchangedata.pojo.entity.mysql.operation.gj.BikeHireRestore;
import com.supcon.exchangedata.pojo.entity.mysql.operation.gj.SgjjtCityIndicator;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *   公交运营实时指数
 * @Author: yangbin
 * @Date: 2022/04/20/9:00
 * @Description:
 */
public interface SlaveGjOperationInfo2 extends JpaRepository<SgjjtCityIndicator, Long> {


    @Transactional
    @Query(nativeQuery = true, value = "SELECT * FROM sgjjt_city_indicator where tongid = (SELECT MAX(tongid) from sgjjt_city_indicator)")
    SgjjtCityIndicator findTopData();

    @Transactional
    @Query(nativeQuery = true, value = "SELECT * FROM sgjjt_city_indicator where date_time >= ?1 and date_time <= ?2 GROUP BY hours,DATE_FORMAT(date_time,'%Y-%m-%d') ORDER BY date_time desc")
    List<SgjjtCityIndicator> busOperationData(LocalDateTime startTime, LocalDateTime endTime);
}
